package com.xjy.web.controller.controller;

import com.xjy.common.annotation.Log;
import com.xjy.common.core.controller.BaseController;
import com.xjy.common.core.domain.AjaxResult;
import com.xjy.common.core.page.TableDataInfo;
import com.xjy.common.enums.BusinessType;
import com.xjy.common.utils.poi.ExcelUtil;
import com.xjy.system.domain.bo.SysBudgetStatisticsQueryBo;
import com.xjy.system.domain.vo.SysBudgetStatisticsVo;
import com.xjy.system.service.ISysBudgetStatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 预算管理之预算汇总Controller
 *
 * @author mlb
 * @date 2022-03-10
 */
@Api(value = "预算管理之预算汇总控制器", tags = {"预算管理之预算汇总管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/system/budget_statistics")
public class SysBudgetStatisticsController extends BaseController {

    private final ISysBudgetStatisticsService iSysBudgetStatisticsService;

    /**
     * 查询预算管理之预算汇总列表
     */
    @ApiOperation("查询预算管理之预算汇总列表")
    @PreAuthorize("@ss.hasPermi('system:budget_statistics:list')")
    @GetMapping("/list")
    public TableDataInfo<SysBudgetStatisticsVo> list(@Validated SysBudgetStatisticsQueryBo bo) {
		startPage();
        return iSysBudgetStatisticsService.queryPageList(bo);
    }

    /**
     * 导出预算管理之预算汇总列表
     */
    @ApiOperation("导出预算管理之预算汇总列表")
    @PreAuthorize("@ss.hasPermi('system:budget_statistics:export')")
    @Log(title = "预算管理之预算汇总", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<SysBudgetStatisticsVo> export(@Validated SysBudgetStatisticsQueryBo bo) {
        List<SysBudgetStatisticsVo> list = iSysBudgetStatisticsService.queryList(bo);
        ExcelUtil<SysBudgetStatisticsVo> util = new ExcelUtil<SysBudgetStatisticsVo>(SysBudgetStatisticsVo.class);
        return util.exportExcel(list, "预算管理之预算汇总");
    }

    /**
     * 获取预算管理之预算汇总详细信息
     */
    @ApiOperation("获取预算管理之预算汇总详细信息")
    @PreAuthorize("@ss.hasPermi('system:budget_statistics:query')")
    @GetMapping("/{subjectName}")
    public AjaxResult<SysBudgetStatisticsVo> getInfo(@NotNull(message = "主键不能为空")
                                                  @PathVariable("subjectName") String subjectName) {
        return AjaxResult.success(iSysBudgetStatisticsService.queryById(subjectName));
    }

}
